<?php
/**
 * Created by PhpStorm.
 * User: Season
 * Date: 2018/10/10
 * Time: 13:50
 */

namespace app\api\model;

class Banner extends BaseModel
{
    protected $hidden = ['id','delete_time','update_time'];
    public function items(){
        return $this->hasMany ('BannerItem','banner_id','id');
    }
    /**
     * @param $id
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function getBannerByID($id){
        $banner = self::with( ['items' , 'items.img'])->find( $id);
        return $banner;
    }
}